<template>
  <div class="toolbar colorMain">
    <div class="mt-10 mb-10">
      <el-form :inline="true" size="small">
        <el-form-item label="用户ID" ><el-input v-model.trim="queryFrom.user_id"/></el-form-item>
        <el-form-item label="奖励/使用时间"><date-picker v-model="queryFrom.time_range"/></el-form-item>
        <el-form-item label="奖励种类" >
          <el-select v-model="queryFrom.platform_reward_sub_type" clearable multiple collapse-tags placeholder="请选择">
            <el-option v-for="item in options2" :key="item.value" :label="item.label" :value="item.value"/>
          </el-select>
        </el-form-item>
        <el-button size="small" type="primary" @click="sendQuery">搜索</el-button>
      </el-form>
    </div>
    <div><el-button :loading="excelLoad" icon="el-icon-printer" style="float: right;margin: 0 0 10px 0" size="mini" type="success" @click="downExcel" >导出数据</el-button></div>
    <el-form :inline="true" size="small">
      <el-form-item label="全部累加金额:" >{{ resData.sum_price && resData.sum_price.toFixed(3) }}元</el-form-item>
    </el-form>
    <analyse-table :show-summary="true" :table-data="tableData" :key_mapper="key_mapper" :sortable = "false" :min-width = "160" size="small" @sort-change="sortChange"/>
    <el-pagination :current-page.sync="page" :page-size="size" :total.sync="total" class="mt-10" layout="total, sizes, prev, pager, next, jumper" @current-change="currentChange" @size-change="handleSizeChange"/>
  </div>
</template>
<script>
import { pickTimeOne } from '@/model/DateRange'
import { getPlatformRewardEventDetail } from '@/api/table'
import mixins from '@/model/mixins'
export default {
  name: 'Reward',
  mixins: [mixins],
  data() {
    return {
      queryFrom: {
        user_id: '',
        time_range: pickTimeOne,
        platform_reward_sub_type: []
      },
      API: getPlatformRewardEventDetail,
      options2: [
        { label: '系统上分', value: 'system_recharge' },
        { label: '代理奖励', value: 'agent' },
        { label: '红包奖励', value: 'coupon' },
        { label: '充值奖励', value: 'pay_bonus' },
        { label: '活动奖励', value: 'campaign' }
      ]
    }
  }
}
</script>
